blob: d71fcf8dd4e778ff371699c37b7d906b8fa981db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---
import AuthorCard from '@/components/AuthorCard.astro'
import BlogCard from '@/components/BlogCard.astro'
import Breadcrumbs from '@/components/Breadcrumbs.astro'
import PageHead from '@/components/PageHead.astro'
import Layout from '@/layouts/Layout.astro'
import { getAllAuthors, getPostsByAuthor } from '@/lib/data-utils'
export async function getStaticPaths() {
const authors = await getAllAuthors()
return authors.map((author) => ({
params: { id: author.id },
props: { author },
}))
}
const { author } = Astro.props
const authorPosts = await getPostsByAuthor(author.id)
---
<Layout class="max-w-3xl">
<PageHead
slot="head"
title={`${author.data.name} (Author)`}
description={author.data.bio || `Profile of ${author.data.name}.`}
noindex
/>
<Breadcrumbs
items={[
{ href: '/authors', label: 'Authors', icon: 'lucide:users' },
{ label: author.data.name, icon: 'lucide:user' },
]}
/>
<section>
<AuthorCard author={author} />
</section>
<section class="flex flex-col gap-y-4">
<h2 class="text-2xl font-medium">Posts by {author.data.name}</h2>
{
authorPosts.length > 0 ? (
<ul class="flex flex-col gap-4">
{authorPosts
.filter((post) => !post.data.draft)
.map((post) => (
<li>
<BlogCard entry={post} />
</li>
))}
</ul>
) : (
<p class="text-muted-foreground">
No posts available from this author.
</p>
)
}
</section>
</Layout>
|